home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / prog / graphics / inside.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  818 b   |  56 lines

  1. #include <LEDA/plane.h>
  2. #include <LEDA/window.h>
  3.  
  4. main()
  5.  
  6. { window W;
  7.  
  8.  
  9.   string   s[5];
  10.  
  11.   s[0] = "no grid ";
  12.   s[1] = "10 pixel";
  13.   s[2] = "20 pixel";
  14.   s[3] = "30 pixel";
  15.   s[4] = "40 pixel";
  16.  
  17.   int grid_width = 10 * W.read_panel("GRID MODE ? ",5,s);
  18.  
  19.   W.clear();
  20.  
  21.   W.init(0,1000,0, grid_width);
  22.   W.set_node_width(2);
  23.  
  24.  
  25.   polygon P;
  26.  
  27.   W >> P;
  28.  
  29.   W << P;
  30.  
  31.   int key;
  32.  
  33.   double x,y;
  34.  
  35.   while ((key = W.read_mouse(x,y)) !=3) 
  36.   { point p(x,y);
  37.     W << p; 
  38.     if (key == 1)
  39.     { if (P.inside(p)) W.draw_text(p,"INSIDE");
  40.       else W.draw_text(p,"OUTSIDE");
  41.      }
  42.     else
  43.     { W.clear();
  44.       W << P; 
  45.       int n = W.read_int("n = ");
  46.       while (n--)
  47.       { p = point(random(0,1000),random(0,1000));
  48.         if (P.inside(p)) W.draw_filled_node(p);
  49.         else W << p;
  50.        }
  51.      }
  52.   }
  53.  
  54.   return 0;
  55. }
  56.